package com.ict.web.controller.yzq;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ict.web.dto.SupplementaryDeclarationAddDto;
import com.ict.web.dto.SupplementaryDeclarationEditDto;
import com.ict.web.vo.SupplementaryDeclarationVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ict.common.annotation.Log;
import com.ict.common.core.controller.BaseController;
import com.ict.common.core.domain.AjaxResult;
import com.ict.common.enums.BusinessType;
import com.ict.web.domain.SupplementaryDeclaration;
import com.ict.web.service.ISupplementaryDeclarationService;
import com.ict.common.utils.poi.ExcelUtil;
import com.ict.common.core.page.TableDataInfo;

/**
 * 增补申报--刘杰Controller
 *
 * @author ruoyi
 * @date 2022-02-25
 */
@Api(tags = "增补申报")
@RestController
@RequestMapping("/supplementaryDeclaration")
public class SupplementaryDeclarationController extends BaseController
{
    @Autowired
    private ISupplementaryDeclarationService supplementaryDeclarationService;

    /**
     * 查询增补申报--刘杰列表
     */
//    @PreAuthorize("@ss.hasPermi('web:declaration:list')")
    @ApiOperation("查询增补申报")
    @GetMapping("/list")
    public TableDataInfo list(SupplementaryDeclaration supplementaryDeclaration)
    {
        startPage();
        List<SupplementaryDeclaration> list = supplementaryDeclarationService.selectSupplementaryDeclarationList(supplementaryDeclaration);
        return getDataTable(list);
    }

    /**
     * 导出增补申报--刘杰列表
     */
//    @PreAuthorize("@ss.hasPermi('web:declaration:export')")
    @ApiOperation("导出增补申报")
    @Log(title = "增补申报--刘杰", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SupplementaryDeclaration supplementaryDeclaration)
    {
        List<SupplementaryDeclaration> list = supplementaryDeclarationService.selectSupplementaryDeclarationList(supplementaryDeclaration);
        ExcelUtil<SupplementaryDeclaration> util = new ExcelUtil<SupplementaryDeclaration>(SupplementaryDeclaration.class);
        util.exportExcel(response, list, "增补申报--刘杰数据");
    }

    /**
     * 获取增补申报--刘杰详细信息
     */
//    @PreAuthorize("@ss.hasPermi('web:declaration:query')")
    @ApiOperation("获取增补申报")
    @GetMapping(value = "/{supplementaryId}")
    public SupplementaryDeclarationVo getInfo(@PathVariable("supplementaryId") Long supplementaryId)
    {
        return supplementaryDeclarationService.selectSupplementaryDeclarationBySupplementaryId(supplementaryId);
    }

    /**
     * 新增增补申报--刘杰
     */
//    @PreAuthorize("@ss.hasPermi('web:declaration:add')")
    @ApiOperation("新增增补申报")
    @Log(title = "增补申报--刘杰", businessType = BusinessType.INSERT)
    @PostMapping
    public Long add(@RequestBody SupplementaryDeclarationAddDto dto)
    {
        return supplementaryDeclarationService.insertSupplementaryDeclaration(dto);
    }

    /**
     * 修改增补申报--刘杰
     */
//    @PreAuthorize("@ss.hasPermi('web:declaration:edit')")
    @ApiOperation("修改增补申报")
    @Log(title = "增补申报--刘杰", businessType = BusinessType.UPDATE)
    @PutMapping("/edit/{supplementaryId}")
    public AjaxResult edit(@RequestBody SupplementaryDeclarationEditDto dto,@PathVariable Long supplementaryId)
    {
        return toAjax(supplementaryDeclarationService.updateSupplementaryDeclaration(dto,supplementaryId));
    }

    /**
     * 删除增补申报--刘杰
     */
//    @PreAuthorize("@ss.hasPermi('web:declaration:remove')")
    @ApiOperation("删除增补申报")
    @Log(title = "增补申报--刘杰", businessType = BusinessType.DELETE)
	@DeleteMapping("/{supplementaryId}")
    public AjaxResult remove(@PathVariable Long supplementaryId)
    {
        return toAjax(supplementaryDeclarationService.deleteSupplementaryDeclarationBySupplementaryId(supplementaryId));
    }
}
